package objects;

import java.util.ArrayList;

import parser.Entry;
import utils.Damage_skill_data;
import utils.Ids_actions;

public class Skill_direct {

	protected ArrayList<Entry> entries;
	protected Long target;
	protected Long Skill_id;
	protected Damage_skill_data datas;
	protected ArrayList<Entry> skill_data;
	public Skill_direct(Long target, Long skill_id){
		this.target = target;
		this.Skill_id = skill_id;
		this.entries = new ArrayList<Entry>();
	}
	public void add(Entry one_entry){
		this.entries.add(one_entry);
	}
	public void print_skill_data(){
		for(int i = 0; i<this.skill_data.size();i++){
			//if(this.skill_data.get(i).getMyskill().getSkillevent_action_id().equals(Skill_id)){
				System.out.println(this.skill_data.get(i).getLine());
		//	}
		}
	}
	public void populate_skill_direct(){
		this.skill_data = new ArrayList<Entry>();
		for(int i = 0; i<this.entries.size();i++){
			if(this.entries.get(i).getMyskill().getSkillevent_id().equals(Ids_actions.applicationeffet)){
				this.skill_data.add(this.entries.get(i));
			}
		}
	}
	
	
	public void calculate_informations(){
		this.populate_skill_direct();
		this.datas = new Damage_skill_data();
		for(int i = 0;i<this.skill_data.size();i++){
			if(this.skill_data.get(i).getMyskill().getNumeric_value()!=null){
			//System.out.println(this.skill_data.get(i).getLine());
				if(this.skill_data.get(i).getMyskill().isCrit()){
					this.datas.incrementNb_crit(1);
					this.datas.incrementSum_crit(this.skill_data.get(i).getMyskill().getNumeric_value());
					this.datas.setCrit_max(this.skill_data.get(i).getMyskill().getNumeric_value());
					this.datas.setCrit_min(this.skill_data.get(i).getMyskill().getNumeric_value());
				}else{
					this.datas.incrmentNb_normal(1);
					this.datas.incrementSum_normal(this.skill_data.get(i).getMyskill().getNumeric_value());
					this.datas.setNormal_max(this.skill_data.get(i).getMyskill().getNumeric_value());
					this.datas.setNormal_min(this.skill_data.get(i).getMyskill().getNumeric_value());
				}
			}
		}
		this.datas.calculateMoyenne();
		this.datas.calculateMoyenne_crit();
		this.datas.calculateMoyenne_normal();
	}

	public Long getTarget() {
		return target;
	}

	public Long getSkill_id() {
		return Skill_id;
	}

	public Damage_skill_data getDatas() {
		return datas;
	}
	
}
